package com.zhang.controller;

import com.github.pagehelper.PageInfo;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.zhang.domain.Department;
import com.zhang.domain.DepartmentVO;
import com.zhang.query.DepartmentQuery;
import com.zhang.service.Impl.DepartmentServiceImpl;
import com.zhang.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.FileInputStream;
import java.util.List;

/**
 * @author zh
 * @create 2022-02-21 14:09
 */
@RestController
@RequestMapping("upload")
public class uploadController {

    @Autowired
    private FastFileStorageClient fastFileStorageClient;
    @PostMapping("add")
    private AjaxResult upload(MultipartFile file){
        try {
            String end = file.getOriginalFilename().split("[.]")[1];
            StorePath path = fastFileStorageClient.uploadFile(file.getInputStream(), file.getSize(), end, null);
            return AjaxResult.me(path);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me(false,"查询失败");
        }
    }

}
